
//
//	cove.display.Stage - 2011 May 10th
//
//	The Point object represents a location in a two-dimensional coordinate system, where x
//	represents the horizontal axis and y represents the vertical axis. 
//
//-------------------------------------------------------------------------------------------------

var Stage = cove.display.Stage = cove.display.DisplayObjectContainer.extend({
	
	init: function(element) {
		this._htmlElement = document.createElement('div');
		this._htmlElement.className = xb.Element.prefix + 'Stage';
		this._parentElement = element;
		
		element.appendChild(this._htmlElement);
		
		DisplayObject.fn.init.call(this);
		
		this._stage = this;
		this._root = this;
		
		this._enterFrames = [];
		
		frameRate = 24;
	},
	
	_controller: function(stage) {
		var i, len = stage._enterFrames.length;
		for(i = 0; i < len; i++) {
			stage._enterFrames[i].dispatchEvent(new Event(Event.ENTER_FRAME));
		}
	},
	
	get stageWidth() { return this._htmlElement.offsetWidth; },
	set stageWidth(v) {
		this._htmlElement.style.width = v + 'px';
		this._parentElement.style.width = v + 'px';
	},
	
	get stageHeight() { return this._htmlElement.offsetHeight; },
	set stageHeight(v) {
		this._htmlElement.style.height = v + 'px';
		this._parentElement.style.height = v + 'px';
	},
	
	get frameRate() { return this._frameRate; },
	set frameRate(v) {
		this._frameRate = v;
		if(this._interval) clearInterval(this._interval);
		this._interval = setInterval(this._controller, Math.round(1000 / v), this);
	}	
});
